import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({

  state: {
    // 存储token
    Authorization: window.localStorage.getItem('Authorization') == null ? '' : window.localStorage.getItem('Authorization' || '[]')
  },

  mutations: {
    // 修改token，并将token存入localStorage
    changeLogin (state, Authorization) {
      state.Authorization = Authorization;
      window.localStorage.setItem('Authorization', Authorization);
    },
    logout (state) {
      state.Authorization = '';
      window.localStorage.removeItem('Authorization')
    }
  }

});

